package views
{
	import flash.display.Sprite;
	
	import models.vo.UserVO;
	
	import org.dexter.DexterFramework;
	import org.dexter.sendDexterEvent;
	
	public class P2PVideo extends Sprite
	{
		public var index:int;
		public var user:UserVO;
		public var cv:CameraVideo;
		public var sv:StreamVideo;
		public function P2PVideo(width:int=320, height:int=240)
		{
			super();
			cv = new CameraVideo(width,height);
			sv = new StreamVideo(width,height);
			addChild(cv);
			addChild(sv);
		}
		public function setUser(user:UserVO):void{
			if(user){
				if(user.isSelf&&!DexterFramework.getProperty("videoCtrl","useFMLE")){
					sv.stopStream();
					cv.play();
				}else{
					sv.playStream(sendDexterEvent("getStream",user.id));
					cv.stop();
				}
			}else{
				sv.stopStream();
				cv.stop();
			}
			this.user = user;
		}
		public function resize(width:int,height:int):void{
			cv.width = width;
			cv.height = height;
			sv.resize(width,height);
		}
	}
}